import type { LogOutputChannel } from "vscode";

export class Logger {

    private static outputChannel: LogOutputChannel | undefined

    static init(outputChannel: LogOutputChannel) {
        Logger.outputChannel = outputChannel
    }

    static log(message: string) {
        if (Logger.outputChannel) {
            Logger.outputChannel.appendLine(message)
        } else {
            console.log(`[Logger] ${message}`)
        }
    }

    static info(message: string) {
        if (Logger.outputChannel) {
            Logger.outputChannel.appendLine(`[INFO] ${message}`)
        } else {
            console.log(`[INFO] ${message}`)
        }
    }

    static warn(message: string) {
        if (Logger.outputChannel) {
            Logger.outputChannel.appendLine(`[WARN] ${message}`)
        } else {
            console.warn(`[WARN] ${message}`)
        }
    }

    static error(message: string) {
        if (Logger.outputChannel) {
            Logger.outputChannel.appendLine(`[ERROR] ${message}`)
        } else {
            console.error(`[ERROR] ${message}`)
        }
    }
}